// SearchTask.h
#ifndef SEARCHTASK_H
#define SEARCHTASK_H

#include <QRunnable>
#include <QList>
#include <QModelIndex>
#include <QObject>
#include <QString>
#include "mainwindow.h"

class SearchTask : public QRunnable {
public:
    SearchTask(MainWindow *mainWindow, const QList<QString> &list, const QString &searchText,bool isFolder=true);

    void checkCurrentFolder(QList<QModelIndex> results, QDir dir);

    bool checkStop();

    void searchRecursively(const QDir &dir, QList<QModelIndex> &results,
                           int currentDepth, int maxDepth, int maxResults);
protected:
    void run() override;

private:
    MainWindow *m_mainWindow;
    QList<QString> m_path;
    QString m_searchText;
    bool isFolder;
};

#endif // SEARCHTASK_H
